package main

import (
	//"web/op"
	"log"
	"web/conf"
	//"runtime"
	"reflect"
	"web/db"
)

func get_count(args ...interface{}) int {
	db1 := db.Connect()
	defer db1.Close()
	var res1 int
	// f: 函数
	var f reflect.Value = reflect.ValueOf(db1.QueryOne)
	// arg: 参数数组
	var arg []reflect.Value
	// 构造 arg
	arg = make([]reflect.Value, len(args)+1)
	arg[0] = reflect.ValueOf(&res1)
	for i := 0; i < len(args); i++ {
		arg[i+1] = reflect.ValueOf(args[i])
	}
	// Call db1.QueryOne
	ret := f.Call(arg)
	if ret[1].Interface() != nil {
		err := ret[1].Interface().(error)
		log.Println(err)
		return 0
	}
	return res1
}

func main() {
	//fmt.Println( op.KeyFmt("  any bit  char ") )
	conf.ReadConfFile("/home/ufhz/easyweb/bin/web.cfg")
	db.Connect()
	var cond_sql = "from files where title like ? and publish=?"
	log.Println("Result:", db.GetCount("fid", cond_sql, "%Linux%", true))
	//fmt.Println(runtime.GOMAXPROCS(-1))
}
